<script>
    let array = [1,4,5,3,2,9,8];
    console.log(array);
    function bubbleSort(arr) {
        let flag = false;
        for(let i = 0;i<arr.length-1;i++) {
            flag = false;
            for(let j = 0;j<arr.length-i-1;j++) {
                if(arr[j]>arr[j+1]) {
                    let tem = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = tem;
                    flag = true;
                }
            }
            if(flag == false) {
                break;
            }
            
        }
        return arr;
    }
    function quickSoleSort(arr) {
        quickHoleSort(arr,0,arr.length-1);
    }
    function oneQuickSoleSort(arr,left,right) {
        let cur = arr[left];
        while(left<right) {
            while(left<right && arr[right]>=cur) {
                right--;
            }
            arr[left] = arr[right];
            while(left<right && arr[left] <= cur) {
                left++;
            }
            arr[right] = arr[left];
        }
        arr[left] = cur;
        return left;
    }
    function quickHoleSort(arr,left,right) {
        if(left>=right) {
            return;
        }
        let src = oneQuickSoleSort(arr,left,right);
        quickHoleSort(arr,left,src-1);
        quickHoleSort(arr,src+1,right);
    }
    quickSoleSort(array);
    console.log(array);
    
    
</script>
